package com.jzr.bedside.controller.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jzr.bedside.db1.model.TPatientView;
import com.jzr.bedside.db1.service.TPatientViewService;
import com.jzr.common.entity.vo.Result;
import com.jzr.common.util.U;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "住院记录接口")
@RestController
@RequestMapping("/api/patientView")
public class PatientViewController {
    @Autowired
    private TPatientViewService patientViewService;

    @ApiOperation("获取住院记录列表")
    @GetMapping("/get")
    public Result<List<TPatientView>> get(@ApiParam("住院记录查询参数") TPatientView record){
        if(record == null){
            return Result.fail("参数不能为空");
        }
        if(U.isBlank(record.getPatientCode())){
            return Result.fail("patientCode不能为空");
        }
        QueryWrapper<TPatientView> qw = new QueryWrapper<>();
        if(U.isNotBlank(record.getPatientCode())) {
            qw.eq(TPatientView.PatientCode_,record.getPatientCode());
        }
        if(U.isNotBlank(record.getCureNo())){
            qw.eq(TPatientView.CureNo_,record.getCureNo());
        }

        List<TPatientView> list = patientViewService.list(qw);
        return Result.success("成功",list,list==null ? 0:list.size());
    }

}
